package com.five.api.controller;


import com.five.api.service.CollectionService;
import com.five.controller.BaseController;
import com.five.qo.ArticleCollectionQO;
import com.five.vo.BaseResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 收藏表 前端控制器
 * </p>
 *
 * @author star
 * @since 2021-06-16
 */
@RestController
@CrossOrigin
@RequestMapping("collection")
@Api(tags = "查询用户收藏文章的接口")
public class CollectionController extends BaseController {

    @Autowired
    private CollectionService collectionService;

    @PostMapping("selectCollectionById")
    @ApiOperation(value = "查询收藏文集接口")
    public BaseResultVO selectCollectionById(@ApiParam(value = "用户id") @RequestParam("userId") Long userId){
        if (userId==0 || userId==null){
            return errorResp("用户id为空");
        }

        List<ArticleCollectionQO> articleCollections = collectionService.selectCollectionByUserId(userId);

        return successResp(articleCollections);
    }



}
